require("utils")
require("tier2")
require("gems") -- gems.lua
require("enchants") -- enchants.lua
require("eq") -- eq.lua
require("buffs") -- buffs.lua
require("races") -- races.lua

local g_red, g_blue, g_yellow =
	gems.orange.hit4agi4,
	gems.purple.str4stam6,
	gems.yellow.hit8

local warrior = {
	race = "HUMAN",
	class = "WARRIOR",
	level = 70,
	can_parry = true,
	can_block = true,
	innate = {
		strength = 144,
		agility = 96,
		stamina = 132,
		intellect = 33,
		spirit = 51,
		skill_defense = 350,
		maxhealth = 4440,
	},
	auras = {
		{ type = "modifier", attribute = "spirit", value = 10 }, 
		{ type = "stat", attribute = "parry", value = 2 },
		{ type = "stat", attribute = "meleecrit", value = 5 },
		{ type = "stat", attribute = "meleehit", value = 3 },
		{ type = "modifier", attribute = "meleeattackpower", value = 10 },
	},
}

local eq = {
	head = {
		item = eq.head.f_t5,
		enchant = enchants.head.ap_cenexp,
		socket1 = gems.meta.ap_run,
		socket2 = g_blue,
	},
	neck = {
		item = eq.neck.f_lurker,
	},
	shoulders = {
		item = eq.shoulders.f_t5,
		socket1 = g_yellow,
		socket2 = g_blue,
		enchant = enchants.shoulders.ap_scryer_exalted,
	},
	back = {
		item = eq.back.f_morogrim,
		enchant = enchants.back.agi12,
	},
	chest = {
		item = eq.chest.f_t5,
		socket1 = g_yellow,
		socket2 = g_blue,
		socket3 = g_red,
		enchant = enchants.chest.stat6,
	},
	wrists = {
		item = eq.wrists.f_lurker,
		socket1 = g_blue,
		enchant = enchants.wrists.str12,
	},
	mainhand = {
		item = eq.mainhand.f_alar,
	},
	offhand = {
		item = eq.offhand.f_alar,
	},
	ranged = {
		item = eq.ranged.shuriken,
	},
	hands = {
		item = eq.hands.f_t5,
		enchant = enchants.hands.str15,
	},
	waist = {
		item = eq.waist.f_badge,
		socket1 = g_red,
		socket2 = g_blue,
	},
	legs = {
		item = eq.legs.f_t5,
		socket1 = g_red,
		enchant = enchants.legs.ap_agi,
	},
	feet = {
		item = eq.feet.f_morogrim,
		enchant = enchants.feet.agility,
	},
	finger1 = {
		item = eq.finger.f_lurker,
	},
	finger2 = {
		item = eq.finger.f_kara,
	},
	trinket1 = {
		item = eq.trinket.f_solarian,
	},
	trinket2 = {
		item = eq.trinket.zuljin,
	},
}

local b = {
	buffs.mark_of_the_wild,
	buffs.well_fed_strength,
	buffs.blessing_kings,
	buffs.blessing_might_ex,
	buffs.battle_shout_ex,
}

utils.InsertAuras(warrior, utils.GetEquipmentAuras(eq))
utils.InsertAuras(warrior, b)

function main()
	local v = tier2.calc(warrior)

--	for k, v in pairs(v) do
--		if v and v ~= 0 then
--			print(k, v)
--		end
--	end
	local ap = v.meleeattackpower
	print(ap, ap / 14, ap *.45)
	local ap_dps = ap / 14
	local w_speed, w_min, w_max = 2.7, 182, 339
	local w_dps = (w_min + w_max) / 2 / w_speed
	local ap_bonus = math.floor(ap_dps * w_speed)
	local d_min, d_max = w_min + ap_bonus, w_max + ap_bonus
	print(string.format("%d - %d Damage (%.1f dps)", d_min, d_max, (d_min + d_max) / 2 / w_speed))
	print(string.format("%.2f%% hit, %.2f%% crit", v.meleehit, v.meleecrit))
end

main()
